package com.asl.website.serviceNeed.domain;

/**
 * @author 482944566@qq.com
 * @version 1.0
 * @date 2025-05-22
 */

import com.asl.common.utils.StringUtils;
import com.asl.website.common.Language;

/**
 * 服务信息响应DTO
 */
public class ServiceDTO {
    private Long serviceId;
    private Integer typeId;
    private String title;
    private String enTitle;
    private String description;
    private Integer sortOrder;
    private String language;

    public ServiceDTO(SysServiceNeed service, String language) {
        this.serviceId = service.getServiceId();
        this.enTitle=service.getEnTitle();
        this.typeId = service.getTypeId();
        this.sortOrder=service.getSortOrder();
        this.language = language;

        switch (Language.fromCode(language)) {
            case EN_US:
                this.title = StringUtils.firstNonBlank(service.getServiceNameEn(), service.getServiceNameZh());
                this.description = StringUtils.firstNonBlank(service.getDetailDescEn(), service.getDetailDescZh());
                break;
            case DE_DE:
                this.title = StringUtils.firstNonBlank(service.getServiceNameDe(), service.getServiceNameZh());
                this.description = StringUtils.firstNonBlank(service.getDetailDescDe(), service.getDetailDescZh());
                break;
            default: // 默认中文
                this.title = service.getServiceNameZh();
                this.description = service.getDetailDescZh();
        }
    }

    public Integer getSortOrder() {
        return sortOrder;
    }

    public String getEnTitle() {
        return enTitle;
    }

    // getters
    public Long getServiceId() {
        return serviceId;
    }

    public Integer getTypeId() {
        return typeId;
    }

    public String getTitle() {
        return title;
    }

    public String getDescription() {
        return description;
    }

    public String getLanguage() {
        return language;
    }

}